<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.content{
				width: 300px;
				height: 300px;
				margin: 50px auto;
				border: 2px solid red;
			}
		</style>
	</head>

	<body>
		<div class="content">
			<h1>请登录</h1>
			<p>
				用户：<input placeholder="用户名不不少于三个字符" type="text" name="" id="username" value="" />
			</p>
			<p>
				密码：<input placeholder="请输入密码" type="password" name="" id="password" value="" />
			</p>
			<p>
				<input type="button" id="btn" value="登录" />
				
			</p>
		</div>
		

	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		$("#btn").click(function(){
			login()
		})
		
		function login() {
			$.ajax({
				type: "post",
				url: "http://120.48.109.174:8081/user/login",
				data: {
					"username": $("#username").val(),
					"password": $("#password").val()
				},
				async: true,
				success: function(res) {
					console.log(res)
					if(res.status==200){
						alert("登录成功")
						localStorage.setItem("token",res.body.token);
//						window.location.href = "index.html";
					}else{
						alert("登录失败"+res.description);
//						window.location.href = "index.html";
					}
				}
			});
		}
		
		
	</script>

</html>